package imper.graphic.listener;

import imper.engine.entity.Country;
import imper.engine.entity.Resources;
import imper.engine.entity.ResourcesType;
import imper.engine.util.ParameterManager;
import imper.graphic.view.TransportView;

public class RemoveTransportRealListener   implements Runnable
{
	protected ResourcesType _ResourceType;

	protected TransportView _view;

	public RemoveTransportRealListener( ResourcesType pResourceType  , TransportView pView )
	{
		this._ResourceType = pResourceType;
		this._view = pView;
	}
	
	@Override
	public void run()
	{
		Country country = ParameterManager.getInstance().getMainCountry();
		Resources resourceReal = country.getResourceTransportReal().getResources(_ResourceType.getId());
		int newValue = resourceReal.getValue() - 1;
		if( newValue >= 0)
		{
			resourceReal.setValue(newValue);
			this._view.calculateValue();
		}
	}
}